package com.qingfeng.provide;

import com.qingfeng.core.dao.qingfeng.BalanceDetailDao;
import com.qingfeng.core.dao.qingfeng.FengbiDetailDao;
import com.qingfeng.core.entity.qingfeng.BalanceDetail;
import com.qingfeng.core.entity.qingfeng.FengbiDetail;
import com.qingfeng.core.utils.UuidUtil;
import com.qingfeng.provide.service.SchoolService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.math.BigDecimal;
import java.util.Date;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class JunitTest {

    @Autowired
    SchoolService service;
    @Autowired
    FengbiDetailDao fengbiDetailDao;
    @Autowired
    BalanceDetailDao balanceDetailDao;

    @Test
    public void test() {
        fengbiDetailDao.deleteAll();

        // save a couple of customers
        FengbiDetail fengbiDetail = new FengbiDetail();
        fengbiDetail.setId(UuidUtil.generatorUUID());
        fengbiDetail.setBalance(20);
        fengbiDetail.setCreateTime(new Date());
        fengbiDetail.setDescrip("chongzhi");
        fengbiDetail.setReward(20);
        fengbiDetail.setModule(1);
        fengbiDetail.setUser("lwyyy");
        fengbiDetail.setDataId(UuidUtil.generatorUUID());
        fengbiDetailDao.insert(fengbiDetail);
        fengbiDetail.setId(UuidUtil.generatorUUID());
        fengbiDetail.setModule(2);
        fengbiDetailDao.insert(fengbiDetail);

        // fetch all customers
        System.out.println("findAll():");
        System.out.println("-------------------------------");
        for (FengbiDetail customer : fengbiDetailDao.findAll()) {
            System.out.println(customer);
        }

        System.out.println("findByModule");
        System.out.println("--------------------------------");
        //System.out.println(fengbiDetailService.findByUser_idIs(1));


        BalanceDetail balanceDetail = new BalanceDetail();
        balanceDetail.setId(UuidUtil.generatorUUID());
        balanceDetail.setAmount(new BigDecimal(20));
        balanceDetail.setBalance(new BigDecimal(20));
        balanceDetail.setCreateTime(new Date());
        balanceDetail.setDataId(UuidUtil.generatorUUID());
        balanceDetail.setDescrip("setDescrip");
        balanceDetail.setModule(1);
        balanceDetail.setUser("lwyyy");
        balanceDetailDao.insert(balanceDetail);
        balanceDetail.setId(UuidUtil.generatorUUID());
        balanceDetailDao.insert(balanceDetail);
        balanceDetail.setId(UuidUtil.generatorUUID());
        balanceDetailDao.insert(balanceDetail);
        balanceDetail.setId(UuidUtil.generatorUUID());
        balanceDetail.setModule(2);
        balanceDetailDao.insert(balanceDetail);






    /*	 School school=new School();
         school.setArea_id(1);
		 school.setId("asd13");
		 school.setIntroduction("测试介绍1");
		 school.setLatitude_end(123.0);
		 school.setLatitude_start(123.0);
		 school.setLongitude_end(123.0);
		 school.setLongitude_start(123.0);
		 school.setName("测试学校名称1");
		 System.out.println(service.save(school));*/

        //System.out.println(service.getSchoolList(1));
    }
}
